package com.core.controller.SeatReservation;


import com.core.pojo.Result.Result;
import com.core.pojo.SeatReservation.dto.ReservationDTO;
import com.core.service.SeatReservation.ReservationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Delete;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/reservation")
@Tag(name = "预约模块")
@RequiredArgsConstructor
public class ReservationController {
    private final ReservationService reservationService;

    /**
     * 座位预约（不分时间段）
     * @param reservationDTO
     */
    @Operation(summary = "座位预约")
    @PostMapping("/reservation")
    public Result reserveSeat(@RequestBody ReservationDTO reservationDTO) {
        return reservationService.reserveSeat(reservationDTO);
    }

    /**
     * 取消预约
     * @param reservationId 预约信息id
     */
    @Operation(summary = "取消预约")
    @DeleteMapping("/{id}")
    public Result cancelReservation(@PathVariable int reservationId) {
        return reservationService.cancelReservation(reservationId);
    }

    /**
     * 签到
     * @param reservationId
     * @return
     */
    @Operation(summary = "签到")
    @PostMapping("/check-in/{id}")
    public Result checkIn(@PathVariable("id") Long reservationId) {
        return reservationService.checkIn(reservationId);
    }
}
